package com.example.dbmysql.service.impl;

import com.example.dbmysql.mapper.NowStayMapper;
import com.example.dbmysql.pojo.NowStay;
import com.example.dbmysql.pojo.RoomHistory;
import com.example.dbmysql.service.NowStayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NowStayServiceImpl implements NowStayService {
    @Autowired
    private NowStayMapper nowStayMapper;

    @Override
    public void NewRecording(RoomHistory roomHistory) {
         NowStay nowStay = new NowStay();
         nowStay.setStatus(1);
         nowStay.setCardNum(roomHistory.getCardNum());
         nowStay.setStayTime(roomHistory.getStayTime());
         nowStay.setPhone(roomHistory.getStayPhone());
         nowStay.setDepartureTime(roomHistory.getDepartureTime());
         nowStay.setRoomName(roomHistory.getRoomName());
         nowStay.setGuestName(roomHistory.getStayPerson());
         nowStay.setRoomId(roomHistory.getRoomId());
        nowStayMapper.NewRecording(nowStay);
    }

    @Override
    public NowStay selectByRoomId(int roomId) {
        return nowStayMapper.selectByRoomId(roomId);
    }

    @Override
    public void updateTime(String departureTime) {
        nowStayMapper.updateTime(departureTime);
    }

    @Override
    public void updateRoomName(String roomName) {
        nowStayMapper.updateRoomName(roomName);
    }

    @Override
    public List<NowStay> selectAll() {
        return nowStayMapper.selectAll();
    }
}
